import { MenuItemModel, MenuListGetResultModel, MenuParams } from './model/MenuModel'
import { defHttp } from '/@/utils/http/axios'
import { BaseFormId, BaseFormParams, BasicDetailResult } from '../model/baseModel'
// api接口列表
enum Api {
  list = '/admin.menu/list',
  info = '/admin.menu/detail',
  add = '/admin.menu/add',
  edit = '/admin.menu/edit',
  delete = '/admin.menu/delete',
}

/**
 * 获取菜单列表
 * @param {*} params
 */
export const list = (params: MenuParams) => defHttp.get<MenuListGetResultModel>({ url: Api.list, params })

/**
 * 平台菜单详情
 * @param {*} params
 */
export const info = (params: BaseFormId) => defHttp.get<BasicDetailResult<MenuItemModel>>({ url: Api.info, params })

/**
 * 新增记录
 * @param {*} data
 */
export const add = (data: BaseFormParams<MenuItemModel>) => defHttp.post({ url: Api.add, data })

/**
 * 编辑菜单
 * @param {*} data
 */
export const edit = (data: BaseFormParams<MenuItemModel>) => defHttp.post<any>({ url: Api.edit, data })

/**
 * 删除记录
 * @param {*} data
 */
export const deleted = (data: BaseFormId) => defHttp.post<any>({ url: Api.delete, data })
